/**
 * main common class
 */
.main-menu {
  .nav-menu {
    font-size: @h4;
    position: relative;
    z-index: 2;
    .clearfix;

    // top menu
    .menu-item {
      .d_b;
      line-height: 1;
      float: left;

      a {
        display: block;
        padding: @space*2 1em;
      }

      &:last-child {
        .level-menu {
          right: 0;
          left: auto;
        }
      }

      &.active,
      &:hover,
      &:focus {
        //TODO
      }
    }

    .open>.dropdown-menu {
      display: block;
    }

    // dropdown menu
    .expanded {
      position: relative;

      &.level-open {
        .level-menu {
          display: block;
        }
      }

      // sub menu
      .level-menu {
        display: none;
        position: absolute;
        left: 0;
        background-color: #fff;
        min-width: 300px;

        a {
          line-height: 1;
          padding: @space;
        }

        .menu-item {
          position: relative;
          border-top: 1px solid #e5e5e5;
          width: 100%;

          // &:first-child{
          //   border-top: 3px solid #e5e5e5;
          // }
          >a {
            color: @global-color-dark;

            &.is-active,
            &:hover {
              background-color: @bg-lighter;
            }
          }

          &:first-child {
            border-top: 0;
          }

          //三级菜单
          .level-menu {
            position: absolute;
            left: 100%;
            top: 0;
          }
        }

        &.level-open {
          display: block;
        }
      }
    }
  }


  .open {
    >.dropdown-menu {
      display: block;

      >li {}
    }

    >a {
      outline: 0;
    }
  }
}

// drupal default
.navbar {
  background-color: @site-base;
  .main-menu;

  .inner {
    .inside-c-tb;
  }

  .nav-menu {
    .menu-item {
      a {
        padding: @space 1em;
        color: #fff;
        font-family: @font-family-title;

        &:hover {
          background-color: #fff;
          color: @site-base;
        }
      }
    }
  }
}

// main menu v1
.main-menu-v1 {
  background-color: #fff;
  border-bottom: 1px solid @border-color;
  display: none;

  .logo {
    display: none;
  }

  .stuck {
    left: 0;
    right: 0;
    background-color: @site-base;
    border-bottom: 3px solid #02a7f7;
    animation: menu_sticky 0.70s ease-in-out;

    .logo {
      display: block;
      height: 40px;
      padding: 9px 0;
      width: 20%;
    }

    .nav-menu {
      float: right;
      width: 80%;

      .menu-item {
        a {
          color: #fff;

          &:hover {
            background-color: darken(@site-base, 5%);
          }
        }
      }
    }
  }

  .inner {
    .inside-c;
  }

  .main-menu;

  .nav-menu {
    .menu-item {
      a {
        padding: @space 1em;
        color: @global-color-dark;
        font-family: @font-family-title;

        &:hover {
          background-color: @site-base;
          color: #fff;
        }
      }

      &.open {
        a {
          background-color: @site-base;
          color: #fff;
        }
      }
    }

    .expanded {
      .icon {
        display: none;
      }

      .level-menu {
        background-color: @site-base;
        text-align: left;

        .menu-item {
          border-top: 1px solid lighten(@site-base, 5%);

          a {
            color: #fff;

            &.is-active,
            &:hover {
              background-color: darken(@site-base, 2%);
            }
          }
        }
      }
    }

    >.menu-item {
      text-align: center;

      &:nth-last-child(4),
      &:nth-last-child(4)~li {
        width: 25%;
      }

      &:nth-last-child(5),
      &:nth-last-child(5)~li {
        width: 20%;
      }

      &:nth-last-child(6),
      &:nth-last-child(6)~li {
        width: 16.66%;
      }

      &:nth-last-child(7),
      &:nth-last-child(7)~li {
        width: 14.2857%;
      }

      &:nth-last-child(8),
      &:nth-last-child(8)~li {
        width: 12.5%;
      }

      &:nth-last-child(9),
      &:nth-last-child(9)~li {
        width: 11.1111%;
      }

      &:nth-last-child(10),
      &:nth-last-child(10)~li {
        width: 10%;
      }
    }
  }

  @media only screen and (min-width: 992px) {
    display: block;
  }
}

.ui-preview-header {
  .main-menu;

  .nav-menu {
    .menu-item {
      a {
        padding: 27px;

        &.menu-toggle {
          font-size: 18px;
          .animate;
        }
      }

      &:hover {
        .menu-toggle {
          color: #fff;
          background-color: darken(@site-base, 5%);
        }
      }
    }

    .expanded {
      .level-menu {
        min-width: 200px;
        background-color: darken(@site-base, 5%);

        .menu-item {
          border-top: 1px solid darken(@site-base, 7%);

          a {
            color: #fff;
            font-size: 16px;

            &:hover {
              color: #fff;
              background-color: darken(@site-base, 7.5%);
              ;
            }
          }
        }
      }
    }
  }

  @media only screen and (max-width: 768px) {
    .js-main-menu {
      .nav-menu {
        display: none;
      }
    }
  }
}

@keyframes menu_sticky {
  0% {
    margin-top: -120px;
    opacity: 0;
  }

  50% {
    margin-top: -64px;
    opacity: 0;
  }

  100% {
    margin-top: 0;
    opacity: 1;
  }
}

/**
 * sidebar menu common class
 */
.sidebar-menu {
  a {
    color: @text-color;
    font-size: 18px;
    height: 50px;
    line-height: 50px;
    .d_b;
    padding-left: @space;
  }

  // level menu
  .level-menu {
    a {
      font-size: 16px;

      &:hover,
      &.is-active {
        color: @site-base;
      }
    }
  }
}

// sidebar menu v1
.sidebar-menu-v1 {
  .sidebar-menu;

  .nav-menu {

    // level 1
    >.menu-item {
      >a {
        background-color: @global-color-lighter;
        margin-bottom: 2px;
        position: relative;
      }

      &.active {
        >a {
          background-color: @site-base;
          color: #fff;
          font-weight: bold;
        }
      }
    }

    // level sub menu
    .level-menu {
      a {
        position: relative;
        border-bottom: 1px solid @border-color;

        &:before {
          .icon;
          content: "\e817";
          font-size: 12px;
          padding-right: @space-min;
        }
      }

      .menu-item {
        &:last-child {
          a {
            border-bottom: 0;
          }
        }
      }
    }

    // about behaviors
    .expanded {
      .menu-collapse {
        .icon-toggle {
          .f-r;
          padding: 0 @space;

          &:after {
            .icon;
            content: "\e817";
            font-size: 18px;
          }
        }
      }

      .level-menu {
        display: none;
      }

      &.active {
        .level-menu {
          display: block;
        }
      }
    }
  }
}

// toolbar menu
.navbar-static-top {
  // if have multiple style move to style class
  background-color: @site-base;

  border: 0;
  min-height: 50px;

  .navbar-custom-menu {
    .f-r;

    ul,
    li {
      .outside-c;
      .inside-c;
      list-style: none;
    }

    >ul.nav {
      position: relative;
      .f-l;
      .clearfix;

      >li {
        position: relative;
        .f-l;
        .d_b;

        >a {
          color: #fff;
          padding: 15px;
          line-height: 18px;

          &:hover {
            color: #f6f6f6;
            background-color: rgba(0, 0, 0, .1)
          }

          .icon {
            font-size: 18px;
            line-height: 18px;
          }

          .label {
            position: absolute;
            top: 9px;
            right: 7px;
            text-align: center;
            font-size: 9px;
            padding: 2px 3px;
            line-height: .9;
            border: 0;
          }
        }

        .dropdown-menu {
          right: 0;
          left: auto;
          width: 280px;
          padding: 0 0 0 0;
          margin: 0;
          top: 100%;
          border: 1px solid @border-color;
          z-index: 9;

          li {
            border-top: 0;

            &.header {
              border-top-left-radius: 4px;
              border-top-right-radius: 4px;
              border-bottom-right-radius: 0;
              border-bottom-left-radius: 0;
              background-color: #ffffff;
              padding: 7px 10px;
              border-bottom: 1px solid @border-color;
              color: @global-color-dark;
              font-size: 14px;
            }

            .menu {
              max-height: 200px;
              margin: 0;
              padding: 0;
              list-style: none;
              overflow-x: hidden;

              li {
                a {
                  color: @global-color-dark;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  padding: @space-min;
                  display: block;
                  font-size: 12px;
                  white-space: nowrap;
                  border-bottom: 1px solid @border-color;

                  &:hover {
                    background-color: @bg-lighter;
                  }

                  .icon {
                    font-size: 16px;
                    width: 20px;
                  }
                }
              }

              .media {
                &.media-float {
                  img {
                    .f-l;
                    .outside-min-r;
                  }

                  .media-body {
                    margin-left: 50px;

                    p {
                      margin: @space/4 0;
                      overflow: hidden;
                      text-overflow: ellipsis;
                    }
                  }
                }

                .title {
                  position: relative;

                  small {
                    color: @global-color-light;
                    font-size: 12px;
                    position: absolute;
                    top: 0;
                    right: 0;

                    .icon {
                      font-size: inherit;
                      width: auto;
                    }
                  }
                }
              }
            }

            &.footer {
              a {
                border-top-left-radius: 0;
                border-top-right-radius: 0;
                border-bottom-right-radius: 4px;
                border-bottom-left-radius: 4px;
                font-size: 12px;
                background-color: #fff;
                padding: 7px 10px;
                border-bottom: 1px solid #eeeeee;
                color: #444 !important;
                text-align: center;
              }
            }
          }
        }

        @media only screen and (max-width: 991px) {
          position: static;

          .dropdown-menu {
            right: 5%;
          }
        }
      }
    }
  }
}
